#!/usr/bin/python3

import requests
import re
import zjl_util
# import http.client.HTTPResponse
# import gzip


# 正式用账号密码登录
codeStr = '140,55,220,55'
url = "https://kyfw.12306.cn/passport/web/login"
data = {
    'username': 'long655113aaa',
    'password': '1qaz2wsx121221',
    'appid': 'otn',
    'answer': codeStr
}

headers = {
    'Host': 'kyfw.12306.cn',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0',
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
    'Accept-Encoding': 'gzip, deflate, br',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'Content-Length': '71',
    'Origin': 'https://kyfw.12306.cn',
    'Connection': 'keep-alive',
    'Referer': 'https://kyfw.12306.cn/otn/resources/login.html',
    'Cookie': '_passport_session=25db01dd99e64d1aa966caaa4e3f0f319975; _passport_ct=1d459370cc544250b1a3f31a9940639ct1369; RAIL_EXPIRATION=1578681295917; RAIL_DEVICEID=owuTzD0nAKatmqCPjWBDE1-jqmCQysIW3rFSi2rDty6iEQ0sNKHt-dSAAjNkxQvk9QuM9dUkg1f0Cz0O2kFUb5BNcpgijb6bgLsdQY5cxRDdKSP9e-HceS806NMm6QrEduRRXC0ivCqNg9p5Kq--vbkUMNB4zbbK; _jc_save_fromStation=%u5E7F%u5DDE%2CGZQ; _jc_save_toStation=%u5317%u4EAC%2CBJP; _jc_save_fromDate=2020-01-07; _jc_save_toDate=2020-01-03; _jc_save_wfdc_flag=dc; ten_key=QvLzlIgzTvmrEYGXfviWOtclWu3SYhib; ten_js_key=QvLzlIgzTvmrEYGXfviWOtclWu3SYhib; BIGipServerotn=4141285642.24610.0000; BIGipServerpassport=1005060362.50215.0000; route=495c805987d0f5c8c84b14f60212447d'
}

req = requests.session()
url = 'http://www.biquge.info/63_63010/17829278.html'
# response = req.post(url, data=data, headers=headers)

default_header = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
    "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
    "Accept-Encoding": "gzip, deflate, br",
    "Connection": "keep-alive",
    "Upgrade-Insecure-Requests": "1"
}
# response = req.get(url, headers=default_header)
# print("参数：" + str(data))
# print(response.text)

url = "https://ai-w-ysts8.iiszg.com/flw.asp?url=%D4%C1%D3%EF%D0%A1%CB%B5%2F%D4%C1%D3%EF%5F%CE%E4%C1%D6%CB%AB%BD%DC%2F006%2Emp3&jiidx=/play%5F9064%5F52%5F1%5F7%2Ehtml&jiids=/play%5F9064%5F52%5F1%5F5%2Ehtml&id=9064&ji=6&said=52"
default_header = {
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
    "Cache-Control": "max-age=0",
    "Connection": "keep-alive",
    "Cookie": "ASPSESSIONIDAARDCSAD=BJOHAIKBFEDDOPNKKNOMGIEM",
    "Host": "ai-w-ysts8.iiszg.com",
    "Referer": "https://www.ysts8.net/play_9064_52_1_1.html",
    "TE": "Trailers",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0"
}
# response = req.get(url, headers=default_header)
# print(response.text)

s = "'+AQUcZcfI346039+''+DPMKSnfR3460935+''+kfiyusut40145+'?v12+'"
pat = "\+(.*?)\+"
r = re.compile(pat, re.S).findall(s)
print(r)

default_header = {
    "Accept": "video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5",
    "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
    "Connection": "keep-alive",
    "Host": "aod.cos.tx.xmcdn.com",
    "Range": "bytes=0-",
    "Referer": "https://aod.cos.tx.xmcdn.com/group14/M08/1D/DB/wKgDZFV47RugY5XCAJwe0P2A710398.m4a",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0"
}
file_url = ""
file_path = "D:/data/听书吧/第13集.m4a"
